set more off 

use "ssi", clear

local control male married family_size age income hs coll grad white black i.region

eststo clear

local j = 1

gen laggeddv = .

foreach y in change_eco ln_vacation ln_totgiv {

	local mytitle: var label `y'	

	replace laggeddv = l`y'

	eststo: xi: reg d`y' republican independent `control'
	eststo: xi: reg d`y' republican independent `control' laggeddv

	local j = `j' + 1

}

label variable laggeddv "Lagged outcome"

#delimit;

esttab
	using "table5.tex"
	,

		replace
 		gap
		compress
		stats(N r2, fmt(%20.00fc %20.02fc) label("Sample size" "R-squared"))
		booktabs
		cells(b(fmt(2) star) se(par))
		label
 		drop(*region*)
		collabels(none)
		width(\textwidth)
		mgroups(
			"Perceptions" "Vacation" "Giving"
			,
				pattern(1 0 1 0 1 0)
				prefix(\multicolumn{@span}{c}{) suffix(})
				span erepeat(\cmidrule(lr){@span})
		)	
		nomtitles
		;
	
#delimit cr
